package com.xrui.hbaseview.ui.design;


import com.xrui.hbaseview.hbase.Connection;

import javax.swing.*;
import java.awt.*;

public class JListRenderer extends DefaultListCellRenderer {

    private static final long serialVersionUID = 8219559461829225540L;

    private Connection connection;

    public JListRenderer(Connection connection) {
        this.connection = connection;
    }

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        if (value instanceof String) {
            try {
                if (isSelected || cellHasFocus) {
                    // Check the table is meta table or not makes UI slowly, comment those code
                    /*if (TableUtil.isMetaTable((String) value)) {
                        setForeground(Color.darkGray);
                    } else if (!connection.tableEnabled((String) value)) {
                        setForeground(Color.gray);
                    }*/
                }
            } catch (Exception ignore) {
            }
        }
        return component;
    }
}
